﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SqlServer.Server;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Common;
namespace test
{
    public class clsConnect
    {
        Server s ;
        ServerConnection sc ;
        
        private clsConnect()
        {
            sc=new ServerConnection();
        }

        public clsConnect(string ServerName, String UID, string PWD)
            : this()
            
        {
            
            
            sc.LoginSecure = false;
        
            sc.ServerInstance = ServerName;
            sc.Connect();
            s = new Server(sc);
        }
        public clsConnect(string ServerName)
            : this()
        {
            sc.LoginSecure = true;
            sc.ServerInstance = ServerName;
            sc.Connect();
            s = new Server(sc);

            
        }
        
        public List<Database> Databases
        {
            get
            {
                return s.Databases.Cast<Database>().ToList<Database>();
            }

        }
        public bool CDCEnabled(string DBName)
        {
            
            {
                return s.Databases[DBName].CDCEnabled();
            }
        }
    }
}
